package com.scaffold.springbootscaffold.controller;

import com.scaffold.springbootscaffold.websocket.WebSocketHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/ws")
@ConditionalOnProperty(prefix = "websocket", name = "enabled", havingValue = "true")
public class WebSocketController {

    @Resource
    private WebSocketHandler webSocketHandler;

    @PostMapping("/send/{userId}")
    public void sendToUser(@PathVariable String userId, @RequestParam String content) {
        webSocketHandler.sendToUser(userId, content);
    }
} 